<template>
  <div>
    <div
      class="wrapper-container"
      style="display: flex; flex-direction: column; width: 100%; "
    >
      <div class="search-container" style="margin:0">
        <div class="search-container-left" style="display: flex; align-items: center;">
          <div
            class="search-container-item"
            v-for="(select, index) in selectList"
            :key="index"
          >
            <div v-if="select.type === 'select'" class="box">
              <span v-show="select.name">{{ select.name }}</span>

              <el-select
                v-model="select.val"
                style="width: 90px"
                size="mini"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in select.valList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </div>
            <div class="box" v-if="select.type === 'data'">
              <span class="demonstration" v-show="select.name">{{
                select.name
              }}</span>
              <el-date-picker
                v-model="select.val"
                type="date"
                placeholder="选择日期"
                prefix-icon="aaa"
              >
              </el-date-picker>
            </div>
            <div v-if="select.type === 'MultiSelect'" class="box"></div>
            <div v-if="select.type === 'btn'" class="box">
              <span class="demonstration" v-show="select.name">{{
                select.name
              }}</span>
              <el-input
                v-model="select.val"
                placeholder="请输入内容"
              ></el-input>
            </div>
          </div>
          <div class="search-button" @click="queryRegisterList">
            <img src="@/assets/assessment/icon-search.png" alt="" />
            <span>查询</span>
          </div>

          <div style="margin-left: 20px">
            <div
              class="cjrc-button"
              @click="electiveCouse"
            >
              <img src="@/assets/assessment/iconaddd.png" alt="" />
              <span style="margin-left: 10px;">互联网选修课登记</span>
            </div>
            <!-- <el-button type="warning" size="mini" icon="el-icon-circle-plus-outline" @click="electiveCouse">互联网选修课登记</el-button> -->
          </div>
        </div>
      </div>
    </div>

    <div class="body-manual-container">
      <div>
        <ul>
          <li>
            <span class="active">状态</span>
            <span class="active">提交</span>
            <span class="active">平台名称</span>
            <span class="active">选修互联网课程名称</span>
            <span class="active">学时</span>
            <span class="active">备注</span>
          </li>
          <div class="xxk-content" v-for="item in tableData">
            <div class="cont-item" :style="item.sh.zt != '已通过' ? 'color:rgb(255, 56, 25)' : 'color:#51AEF6'">{{item.sh.zt}}</div>
            <div class="cont-item">
              <el-button style="background: #f1f8fe;border: 1px solid #51aef6;color:#51aef6" v-if="item.sh.zt == '待提交'" type="primary" size="mini" icon="el-icon-circle-plus-outline" @click="submit(item)">提交</el-button>
            </div>
            <div class="cont-item spjd">
              <div class="item-list">
                <div>{{item.dj.address}}</div>
                <div>{{item.dj.coursename}}</div>
                <div>{{item.dj.classhour}}</div>
                <div>{{item.dj.remark}}</div>
              </div>
              <div class="item-spjd">
                <div class="spjd">
                  <div class="spjd-title">审批进度：</div>
                  <div class="time-line-horizon">
                    <div class="time-line-block">
                      <div class="person-name">学员</div>
                      <div class="line-content">
                        <!-- 0是待，1是已，null是还没到 -->
                        <img
                         v-if="item.sh.xyzt == 1"
                          src="../../../../../assets/assessment/icon-finish.png"
                          alt=""
                        />
                        <img
                        v-else-if="item.sh.xyzt == '' || item.sh.xyzt == null"
                          src="../../../../../assets/assessment/icon-close.png"
                          alt=""
                        />
                        <img
                        v-else-if="item.sh.xyzt == 0"
                          src="../../../../../assets/assessment/icon-dai.png"
                          alt=""
                        />
                        <div class="date-time">
                          <span class="date">{{item.sh.xydate}}</span>
                        </div>
                      </div>
                      <div class="operate">
                        <div
                          class="ly-block"
                          @click="showAddMessageDialogly = true"
                        >
                          <img
                            src="../../../../../assets/assessment/icon-ly.png"
                            alt=""
                          />
                          <div class="ly">留言</div>
                        </div>
                      </div>
                    </div>
                    <div class="time-line-block"></div>
                    <div class="time-line-block">
                      <div class="person-name">队长</div>
                      <div class="line-content">
                        <img
                         v-if="item.sh.dzzt == 1"
                          src="../../../../../assets/assessment/icon-finish.png"
                          alt=""
                        />
                        <img
                        v-else-if="item.sh.dzzt == ''||item.sh.dzzt == null"
                          src="../../../../../assets/assessment/icon-close.png"
                          alt=""
                        />
                        <img
                        v-else-if="item.sh.dzzt == 0"
                          src="../../../../../assets/assessment/icon-dai.png"
                          alt=""
                        />
                        <div class="date-time">
                          <span class="date">{{item.sh.dzdate}}</span>
                        </div>
                      </div>
                      <div class="operate">
                        <div class="bubble-block">
                          <span
                            >请输入留言请输入请输入留言请输入留言请输入留言</span
                          >
                          <div
                            class="operate-button"
                            @click="showAddMessageDialoglys = true"
                          >
                            <div class="button-sc">查看</div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="time-line-block"></div>
                    <div class="time-line-block">
                      <div class="person-name">管理员</div>
                      <div class="line-content">
                        <img
                         v-if="item.sh.glyzt == 1"
                          src="../../../../../assets/assessment/icon-finish.png"
                          alt=""
                        />
                        <img
                        v-else-if="item.sh.glyzt == '' || item.sh.glyzt == null"
                          src="../../../../../assets/assessment/icon-close.png"
                          alt=""
                        />
                        <img
                        v-else-if="item.sh.glyzt == 0"
                          src="../../../../../assets/assessment/icon-dai.png"
                          alt=""
                        />
                        <div class="date-time">
                          <span class="date">{{item.sh.glydate}}</span>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </ul>
      </div>
    </div>

    <div class="bottom-block" style="display: block">
      <div class="text">
        当前共找到{{ total }}条记录,当前显示{{ startPage }}-{{ endPage }}条
      </div>
    </div>
    <div class="pagination-block">
      <el-pagination
        prev-text="上一页"
        next-text="下一页"
        :page-size="pageSize"
        layout="prev, pager, next, jumper"
        :total="total"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
      >
      </el-pagination>
    </div>

    <el-dialog
      title="留言"
      :visible.sync="showAddMessageDialogly"
      width="983px"
    >
      <div class="message-container">
        <div>添加留言：</div>
        <div>
          <el-input
            v-model="meaasgeText"
            type="textarea"
            :rows="8"
            style="width: 550px"
          ></el-input>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="success" @click="showAddMessageDialogly = false">
          确 定
        </el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="查看留言"
      :visible.sync="showAddMessageDialoglys"
      width="983px"
    >
      <div class="message-container">
        <div>留言详情：</div>
        <div>
          <el-input
            v-model="meaasgeText"
            type="textarea"
            :rows="8"
            style="width: 550px"
          ></el-input>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="success" @click="submitLIUY()">
          确 定
        </el-button>
      </span>
    </el-dialog>

    <el-dialog
      title="互联网选修课登记"
      :visible.sync="electiveCouseDialog"
      width="800px"
    >
      <div class="body-manual-container">
        <div style="width: calc(100% - 100px); margin: 10px 50px">
          <ul>
            <li>
              <span class="active">平台名称</span>
              <span style="width: 300px;"><el-input v-model="platformName"></el-input></span>
            </li>
            <li>
              <span class="active">选修互联网课程名称</span>
              <span style="width: 300px;"><el-input v-model="electiveName"></el-input></span>
            </li>
            <li>
              <span class="active">学时</span>
              <span style="width: 300px;"><el-input v-model="classHours"></el-input></span>
            </li>
            <li>
              <span class="active" style="height: 120px">备注</span>
              <span style="height: 120px;width: 300px;"
                ><el-input
                  v-model="remarks"
                  type="textarea"
                  :rows="3"
                ></el-input
              ></span>
            </li>
          </ul>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="success" @click="saveInfo" style="color: #f3b815;border: 1px solid #f3b815;background: #fff6ef;margin-right:60px">
         保存
        </el-button>
        <el-button type="primary" @click="submitInfo" style="color:#51AEF6;border: 1px solid #51AEF6;background: rgb(241 248 254);margin-right:60px"> 
         保存并通过
        </el-button>
        <el-button type="danger" @click="cancelInfo" style="color: #ff3819;border: 1px solid #ff3819;background: #ffefef;">
         取消
        </el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {queryCommonXueqi, hlwxk_add, hlwxk_submit, hlwxk_addAndSubmit, hlwxk_list, queryDefaultXueQi} from "@/api/trainingManagement/place.js";
import ButtonItem from "@/components/ButtonItem.vue";

export default {
  components: {
    ButtonItem,
  },
  data() {
    return {
      meaasgeText: "", //留言详情：
      platformName: "", //平台名称
      electiveName: "", //选修互联网课程名称
      classHours: "", //学时
      remarks: "", //备注
      showAddMessageDialogly: false, //查看留言
      showAddMessageDialoglys: false, //查看留言
      selectList: [
        {
          type: "select",
          name: "学期:",
          val: "",
          valList: [],
        },
      ],
      electiveCouseDialog: false, //互联网选课登记
      total: 0, //总条数
      pageSize: 50, //条数
      startPage: 0, //开始条数
      endPage: 0, //结束条数
      currentPage: 1, //当前页数
      tableData: [], //表格数据
    };
  },
  created() {},
  mounted() {
    this.queryCommonXueqi();
    this.getDefaultXueQi();
  },
  methods: {
    async getDefaultXueQi(){
      queryDefaultXueQi().then(res=>{
        if(res.data.code == 200){
          this.selectList[0].val = res.data.data;
          // this.semester = res.data.data;
        }
      }).then(()=>{
        this.queryRegisterList()
      })
    },
    // 留言
    submitLIUY() {
      this.showAddMessageDialoglys = false
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.queryRegisterList();
    },
    // 查询
    async queryRegisterList() {
      var xueqi = this.selectList[0].val;
      var current= this.currentPage;
      var size = this.pageSize;
      const res = await hlwxk_list(xueqi, current, size);
      if (res.data.code == 200) {
        this.tableData = res.data.data.records;
        if(this.tableData.length <= 0) {
          this.$message({
            type:'info',
            message:'暂无数据！'
          })
          return
        }
        this.total = res.data.data.total;
        var length = this.tableData.length;
        this.calculatePage(this.pageSize,res.data.data.current, length);
      }
    },
    // 计算开始和结束条数
    calculatePage(pageSize, current, length) {
      if (current == 1) {
        if (length != 0) {
          this.startPage = 1;
          this.endPage = length;
        }
      } else {
        this.startPage = pageSize * (current - 1) + 1;
        this.endPage = parseInt(this.startPage)  + parseInt(length) - 1;
      }
    },
    async submit(item) {
      var data = {
          "registerId": item.sh.registerId,
      }
      const res = await hlwxk_submit(data);
      if (res.data.code == 200) {
        this.$message.success("提交成功!");
        this.cancelInfo();
        this.queryRegisterList();
      }
    },
    // 保存
    async saveInfo() {
      if(this.platformName == "" || this.platformName == null) {
        this.$message.warning("请先输入平台名称!");
        return;
      }
      if(this.electiveName == "" || this.electiveName == null) {
        this.$message.warning("请先输入选修课名称!");
        return;
      }
      if(this.classHours == "" || this.classHours == null) {
        this.$message.warning("请先输入学时!");
        return;
      }
      var xueqi = this.selectList[0].val;
      var data = {
          "coursename": this.platformName,
          "address": this.electiveName,
          "classhour": this.classHours,
          "remark": this.remarks
      }
      const res = await hlwxk_add(xueqi, data);
      if (res.data.code == 200) {
        this.$message.success("保存成功!");
        this.cancelInfo();
        this.queryRegisterList();
      }
    },
    // 提交
    async submitInfo() {
      if(this.platformName == "" || this.platformName == null) {
        this.$message.warning("请先输入平台名称!");
        return;
      }
      if(this.electiveName == "" || this.electiveName == null) {
        this.$message.warning("请先输入选修课名称!");
        return;
      }
      if(this.classHours == "" || this.classHours == null) {
        this.$message.warning("请先输入学时!");
        return;
      }
      var data = {
          "coursename": this.platformName,
          "address": this.electiveName,
          "classhour": this.classHours,
          "remark": this.remarks
      }
      var xueqi = this.selectList[0].val;
      const res = await hlwxk_addAndSubmit(xueqi, data);
      if (res.data.code == 200) {
        this.$message.success("提交成功!");
        this.cancelInfo();
        this.queryRegisterList();
      }
    },
    // 保存
    cancelInfo() {
      this.electiveCouseDialog = false;
      this.platformName = ""; //平台名称
      this.electiveName = ""; //选修互联网课程名称
      this.classHours = ""; //学时
      this.remarks = ""; //备注
    },
    // 获取学期列表
    async queryCommonXueqi() {
      const res = await queryCommonXueqi();
      if (res.data.code == 200) {
        this.selectList[0].valList = res.data.data;
      }
    },
    // 互联网选课登记
    electiveCouse() {
      this.electiveCouseDialog = true;
    },
    // 信息查询
    queryInfo() {},
  },
  computed: {}, //计算属性
};
</script>
<style lang="less" scoped>
.cjrc-button {
  width: 180px;
  height: 28px;
  line-height: 28px;
  background: #fff6ef;
  border: 1px solid #f86900;
  border-radius: 6px;
  color: #f86900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  img {
    width: 14px;
    height: 14px;
    background-size: 100% 100%;
    background-repeat: no-repeat;
  }
}
.assessment-container {
  .el-dialog__body {
    height: 251px;
  }
  .el-dialog__footer {
    padding: 10px 20px 45px;
  }
  .el-checkbox__inner:hover {
    border-color: #004ca7;
  }
  .el-checkbox__inner {
    border: 1px solid #004ca7;
    border-radius: 0;
    height: 18px;
    width: 18px;
  }
  .el-checkbox__inner::after {
    height: 10px;
    left: 6px;
  }
  .el-checkbox__input.is-checked .el-checkbox__inner,
  .el-checkbox__input.is-indeterminate .el-checkbox__inner {
    background-color: #004ca7;
    border-color: #004ca7;
  }
  .el-checkbox__input.is-checked + .el-checkbox__label {
    color: #004ca7;
  }
  .el-checkbox.is-bordered.is-checked {
    border-color: #004ca7;
  }
  .el-checkbox__input.is-focus .el-checkbox__inner {
    border-color: #004ca7;
  }
}
</style>
<style lang="less" scoped>
@import "../../../../../styles/text.less";
.pagination-block {
  margin-top: 20px;
  display: flex;
  flex-direction: row;
  justify-content: center;
}
</style>
<style lang="less" scoped>
@import "../../../../../styles/supervision.less";

.wrapper-container {
  // width: 1711px;
  margin: 0 auto;
}

/deep/ .table-container {
  .el-table td,
  .el-table th.is-leaf,
  .el-table--border,
  .el-table--group {
    border-color: #c7d7eb;
  }

  .el-table__header tr,
  .el-table__header th {
    padding: 0;
    height: 76px;
    background-color: #edf2f9;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    line-height: 20px;
    color: #004ca7;
  }

  .el-table__body tr,
  .el-table__body td {
    padding: 0;
    height: 86px;
  }

  .wrapper-button {
    display: flex;
    flex-direction: column;
    align-items: center;

    > div {
      margin-bottom: 8px;
    }
  }
  .table-data {
    width: 100%;
    border: 0.8px solid #004ca7;
    /*border-radius: 9px;*/
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #004ca7;
  }
}

.wrapper-container .search-container .search-container-left {
  width: 100%;
  flex-wrap: wrap;
  .search-container-item {
    width: 10%;
    margin-right: 0px;
    .box {
      > span {
        text-align: left;
      }
      display: flex;
      justify-content: space-evenly;
      // margin-bottom: 20px;
      align-items: center;
    }
  }
}

/deep/.el-date-editor.el-input {
  width: 110px;
}
/deep/ .el-input--medium {
  width: 110px;
  .el-input__inner {
    height: 28px;
    width: 110px;
    padding: 0px 18px;
  }
}
/deep/ .el-table thead {
  color: #004ca7 !important;
}

.btn {
  margin-top: 271px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 271px;
  .submit {
    width: 84px;
    height: 27px;
    line-height: 8px;
  }
}
.bottom-block {
  // display: flex;
  flex-direction: row;
  justify-content: space-between !important;
  .export-button {
    width: 127px;
    height: 27px;
    background: #fff6ef;
    border: 1px solid #f3b815;
    border-radius: 4px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
    > img {
      width: 17px;
      height: 17px;
    }
    > span {
      margin-left: 12px;
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #f3b815;
    }
  }
  .text {
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    line-height: 39px;
    color: #004ca7;
  }
}

.search-button {
  width: 77px;
  height: 28px;
  line-height: 28px;
  background: #f1f8fe;
  border: 1px solid #51aef6;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  > span {
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #51aef6;
  }
  > img {
    width: 20px;
    height: 20px;
    margin-right: 4px;
  }
}

.body-manual-container {
  > div:nth-child(1) {
    width: calc(100% - 20px);
    // height: 785px;
    border: 1px solid rgba(0, 76, 167, 0.8);
    border-radius: 6px;
    margin: 30px auto 0;
    ul {
      list-style: none;
      li {
        border-bottom: 1px solid rgba(0, 76, 167, 0.4);
        height: auto;
        > span {
          box-sizing: border-box;
          display: inline-block;
          font-size: 14px;
          color: rgba(0, 76, 167, 1);
          padding-left: 54px;
          border-right: 1px solid rgba(0, 76, 167, 0.4);
          height: 60px;
          padding-top: 20px;
          vertical-align: middle;
          &:nth-child(n) {
            width: 200px;
          }
          &:nth-child(4) {
            width: calc(100% - 1000px);
          }
          &:last-child {
            border-right: none;
          }
          &.active {
            font-size: 16px;
            color: rgba(0, 76, 167, 1);
            font-weight: bold;
            background: rgba(77, 129, 192, 0.1);
            text-align: center;
            padding-left: 0;
          }
          > span {
            color: rgba(255, 56, 25, 1);
          }
          > div {
            width: 100%;
          }
          /deep/ .el-input__inner {
            height: 28px;
          }
        }
      }
    }
  }
}

/deep/ .el-tree-node__expand-icon.expanded {
  color: rgb(0, 76, 167);
}
.xxk-content {
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(0, 76, 167, 0.4);
  .cont-item {
    width: 200px;
    border-right: 1px solid rgba(0, 76, 167, 0.4);
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .cont-item:nth-last-child(1) {
    border-right: 0;
  }

  .spjd {
    width: calc(100% - 400px);
    height: 300px;
    display: block;
    // border-bottom: 1px solid rgba(0, 76, 167, 0.4);
    .item-list {
      width: 100%;
      height: 60px;
      border-bottom: 1px solid rgba(0, 76, 167, 0.4);
      color: #004ca7;
      display: flex;
      align-items: center;
      justify-content: center;
      > div:nth-child(n) {
        width: 200px;
        height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-right: 1px solid rgba(0, 76, 167, 0.4);
      }
      > div:nth-child(2) {
        width: calc(100% - 600px);
      }
      > div:nth-last-child(1) {
        border-right: 0;
      }
    }

    .item-spjd {
      height: 240px;
    }
  }
}

.spjd {
  .spjd-title {
    margin: 10px 0 0 18px;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #004ca7;
  }
  .time-line-horizon {
    position: relative;
    margin-left: 129px;
    display: flex;
    flex-direction: row;
    width: 1070px;
    &::before {
      content: "";
      position: absolute;
      top: 35px;
      width: 900px;
      border-bottom: 2px dashed #4b78ac;
    }
    .time-line-block {
      display: flex;
      flex-direction: column;
      width: 225px;
      &:last-child {
        width: 190px;
      }
      .person-name {
        font-size: 14px;
        height: 15px;
        line-height: 15px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #004ca7;
        width: 50%;
        position: relative;
        left: -20%;
        text-align: center;
      }
      .line-content {
        display: flex;
        flex-direction: row;
        align-items: center;
        height: 40px;
        z-index: 100;
        > img {
          width: 26px;
          height: 26px;
        }
        .date-time {
          display: flex;
          flex-direction: column;
          font-size: 12px;
          font-family: Microsoft YaHei;
          font-weight: 400;
          color: #004ca7;
          .date,
          .time {
            margin: 3px 8px;
          }
          .date {
            width: 70px;
          }
        }
      }
      .operate {
        margin-top: 10px;
        position: relative;
        .ly-block {
          cursor: pointer;
          display: flex;
          flex-direction: column;
          align-items: center;
          position: relative;
          left: -8px;
          width: 40px;
          > img {
            width: 33px;
            height: 33px;
          }
          .ly {
            font-size: 14px;
            font-family: Microsoft YaHei;
            font-weight: 400;
            color: #f1b107;
          }
        }
        .bubble-block {
          cursor: pointer;
          left: -60px;
          width: 280px;
          height: 60px;
          background: url(../../../../../assets/assessment/bubble.png) center
            no-repeat;
          background-size: 100%;
          position: relative;
          padding: 15px 10px 5px;
          box-sizing: border-box;
          > span {
            font-size: 14px;
            font-family: Microsoft YaHei;
            font-weight: 400;
            line-height: 20px;
            color: #004ca7;
          }
          .operate-button {
            position: absolute;
            bottom: 8px;
            right: 10px;
            display: flex;
            flex-direction: row;
            align-items: center;
            padding: 0 3px;
            > div {
              width: 37px;
              box-sizing: border-box;
              background: #fff6dc;
              border: 1px solid #f1b107;
              border-radius: 4px;
              margin-left: 6px;
              font-size: 12px;
              font-family: Microsoft YaHei;
              font-weight: 400;
              color: #f1b107;
              text-align: center;
            }
            .button-ck {
              background: #fff6dc;
              border: 1px solid #f1b107;
              color: #f1b107;
            }
            .button-bj {
              background: #ffefef;
              border: 1px solid #fa5339;
              color: #fa5339;
            }
            .button-sc {
              background: #f1f8fe;
              border: 1px solid #51aef6;
              color: #51aef6;
            }
          }
        }
      }
    }
  }
}
.message-container {
  > div {
    display: inline-block;
    &:nth-child(1) {
      padding-left: 111px;
      font-size: 20px;
      color: rgba(0, 76, 167, 1);
      font-weight: bold;
      vertical-align: top;
    }
  }
}
</style>
